home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / procssng / ccs / ccs-11tl.lha / lbl / xview / genial / func / dist.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-07-14  |  933 b   |  51 lines

  1. /*
  2.  * dist.c -- routines for measuring distance
  3.  *
  4.  */
  5.  
  6. #include "ui.h"
  7. #include "display.h"
  8. #include "log.h"
  9. #include "reg.h"
  10. #include "common.h"
  11.  
  12. dist_init()
  13. {
  14.     clear_info();
  15.     lab_info("Please select a line for distance measure", 1);
  16.     lab_info("hit <eval> when finished", 2);
  17.  
  18.     setrtype(LINE);
  19.     reg_setdom(NONE);
  20.  
  21.     return 0;
  22. }
  23.  
  24. dist_eval()
  25. {
  26.     struct dlist *dl;
  27.     double    d;
  28.     static char msg[80];
  29.     XPoint    p1, p2;
  30.  
  31.     dl = curfunc->reg->r_dlist;
  32.     p1.x = dl->points[0].pt.x;
  33.     p1.y = dl->points[0].pt.y;
  34.     p2.x = dl->points[dl->len - 1].pt.x;
  35.     p2.y = dl->points[dl->len - 1].pt.y;
  36.     d = distance(p1, p2);
  37.     sprintf(msg, "Distance from (%d,%d) to (%d,%d): %.2f", 
  38.         p1.x, p1.y, p2.x, p2.y, (float) d);
  39.  
  40.     xv_set(base_win->infomesg, PANEL_LABEL_STRING, msg, NULL);
  41.     panel_paint(base_win->infomesg, PANEL_CLEAR);
  42.  
  43.     return 0;
  44. }
  45.  
  46. dist_clear()
  47. {
  48.     clear_info();
  49.     return 0;
  50. }
  51.